<?php


abstract class BaseDatoPersonal extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $cedulapersonal;


	
	protected $nombre;


	
	protected $apellido;


	
	protected $direccion_hab;


	
	protected $telefono_hab;


	
	protected $telefono_movil;


	
	protected $email;


	
	protected $usuario_id;

	
	protected $aAteneausuario;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getCedulapersonal()
	{

		return $this->cedulapersonal;
	}

	
	public function getNombre()
	{

		return $this->nombre;
	}

	
	public function getApellido()
	{

		return $this->apellido;
	}

	
	public function getDireccionHab()
	{

		return $this->direccion_hab;
	}

	
	public function getTelefonoHab()
	{

		return $this->telefono_hab;
	}

	
	public function getTelefonoMovil()
	{

		return $this->telefono_movil;
	}

	
	public function getEmail()
	{

		return $this->email;
	}

	
	public function getUsuarioId()
	{

		return $this->usuario_id;
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::ID;
		}

	} 
	
	public function setCedulapersonal($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cedulapersonal !== $v) {
			$this->cedulapersonal = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::CEDULAPERSONAL;
		}

	} 
	
	public function setNombre($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->nombre !== $v) {
			$this->nombre = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::NOMBRE;
		}

	} 
	
	public function setApellido($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->apellido !== $v) {
			$this->apellido = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::APELLIDO;
		}

	} 
	
	public function setDireccionHab($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->direccion_hab !== $v) {
			$this->direccion_hab = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::DIRECCION_HAB;
		}

	} 
	
	public function setTelefonoHab($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->telefono_hab !== $v) {
			$this->telefono_hab = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::TELEFONO_HAB;
		}

	} 
	
	public function setTelefonoMovil($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->telefono_movil !== $v) {
			$this->telefono_movil = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::TELEFONO_MOVIL;
		}

	} 
	
	public function setEmail($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::EMAIL;
		}

	} 
	
	public function setUsuarioId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->usuario_id !== $v) {
			$this->usuario_id = $v;
			$this->modifiedColumns[] = DatoPersonalPeer::USUARIO_ID;
		}

		if ($this->aAteneausuario !== null && $this->aAteneausuario->getId() !== $v) {
			$this->aAteneausuario = null;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->cedulapersonal = $rs->getString($startcol + 1);

			$this->nombre = $rs->getString($startcol + 2);

			$this->apellido = $rs->getString($startcol + 3);

			$this->direccion_hab = $rs->getString($startcol + 4);

			$this->telefono_hab = $rs->getString($startcol + 5);

			$this->telefono_movil = $rs->getString($startcol + 6);

			$this->email = $rs->getString($startcol + 7);

			$this->usuario_id = $rs->getInt($startcol + 8);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 9; 
		} catch (Exception $e) {
			throw new PropelException("Error populating DatoPersonal object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DatoPersonalPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			DatoPersonalPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DatoPersonalPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aAteneausuario !== null) {
				if ($this->aAteneausuario->isModified()) {
					$affectedRows += $this->aAteneausuario->save($con);
				}
				$this->setAteneausuario($this->aAteneausuario);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = DatoPersonalPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += DatoPersonalPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aAteneausuario !== null) {
				if (!$this->aAteneausuario->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aAteneausuario->getValidationFailures());
				}
			}


			if (($retval = DatoPersonalPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DatoPersonalPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getCedulapersonal();
				break;
			case 2:
				return $this->getNombre();
				break;
			case 3:
				return $this->getApellido();
				break;
			case 4:
				return $this->getDireccionHab();
				break;
			case 5:
				return $this->getTelefonoHab();
				break;
			case 6:
				return $this->getTelefonoMovil();
				break;
			case 7:
				return $this->getEmail();
				break;
			case 8:
				return $this->getUsuarioId();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DatoPersonalPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getCedulapersonal(),
			$keys[2] => $this->getNombre(),
			$keys[3] => $this->getApellido(),
			$keys[4] => $this->getDireccionHab(),
			$keys[5] => $this->getTelefonoHab(),
			$keys[6] => $this->getTelefonoMovil(),
			$keys[7] => $this->getEmail(),
			$keys[8] => $this->getUsuarioId(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DatoPersonalPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setCedulapersonal($value);
				break;
			case 2:
				$this->setNombre($value);
				break;
			case 3:
				$this->setApellido($value);
				break;
			case 4:
				$this->setDireccionHab($value);
				break;
			case 5:
				$this->setTelefonoHab($value);
				break;
			case 6:
				$this->setTelefonoMovil($value);
				break;
			case 7:
				$this->setEmail($value);
				break;
			case 8:
				$this->setUsuarioId($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DatoPersonalPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCedulapersonal($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setNombre($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setApellido($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setDireccionHab($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setTelefonoHab($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setTelefonoMovil($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setEmail($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setUsuarioId($arr[$keys[8]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(DatoPersonalPeer::DATABASE_NAME);

		if ($this->isColumnModified(DatoPersonalPeer::ID)) $criteria->add(DatoPersonalPeer::ID, $this->id);
		if ($this->isColumnModified(DatoPersonalPeer::CEDULAPERSONAL)) $criteria->add(DatoPersonalPeer::CEDULAPERSONAL, $this->cedulapersonal);
		if ($this->isColumnModified(DatoPersonalPeer::NOMBRE)) $criteria->add(DatoPersonalPeer::NOMBRE, $this->nombre);
		if ($this->isColumnModified(DatoPersonalPeer::APELLIDO)) $criteria->add(DatoPersonalPeer::APELLIDO, $this->apellido);
		if ($this->isColumnModified(DatoPersonalPeer::DIRECCION_HAB)) $criteria->add(DatoPersonalPeer::DIRECCION_HAB, $this->direccion_hab);
		if ($this->isColumnModified(DatoPersonalPeer::TELEFONO_HAB)) $criteria->add(DatoPersonalPeer::TELEFONO_HAB, $this->telefono_hab);
		if ($this->isColumnModified(DatoPersonalPeer::TELEFONO_MOVIL)) $criteria->add(DatoPersonalPeer::TELEFONO_MOVIL, $this->telefono_movil);
		if ($this->isColumnModified(DatoPersonalPeer::EMAIL)) $criteria->add(DatoPersonalPeer::EMAIL, $this->email);
		if ($this->isColumnModified(DatoPersonalPeer::USUARIO_ID)) $criteria->add(DatoPersonalPeer::USUARIO_ID, $this->usuario_id);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(DatoPersonalPeer::DATABASE_NAME);

		$criteria->add(DatoPersonalPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCedulapersonal($this->cedulapersonal);

		$copyObj->setNombre($this->nombre);

		$copyObj->setApellido($this->apellido);

		$copyObj->setDireccionHab($this->direccion_hab);

		$copyObj->setTelefonoHab($this->telefono_hab);

		$copyObj->setTelefonoMovil($this->telefono_movil);

		$copyObj->setEmail($this->email);

		$copyObj->setUsuarioId($this->usuario_id);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new DatoPersonalPeer();
		}
		return self::$peer;
	}

	
	public function setAteneausuario($v)
	{


		if ($v === null) {
			$this->setUsuarioId(NULL);
		} else {
			$this->setUsuarioId($v->getId());
		}


		$this->aAteneausuario = $v;
	}


	
	public function getAteneausuario($con = null)
	{
				include_once 'lib/model/om/BaseAteneausuarioPeer.php';

		if ($this->aAteneausuario === null && ($this->usuario_id !== null)) {

			$this->aAteneausuario = AteneausuarioPeer::retrieveByPK($this->usuario_id, $con);

			
		}
		return $this->aAteneausuario;
	}

} 